layui.use(['carousel', 'dropdown', 'form', 'jquery', 'table', 'element'], function () {
  var carousel = layui.carousel
    , form = layui.form
    , dropdown = layui.dropdown
    , $ = layui.$
    , table = layui.table
    , element = layui.element;

  // 点击函数
  payClick = function () {
    console.log("支付接口");
    car_id = $('.layui-form-checked').prev().val()
    $.ajax({
        type: "POST",
        url: '/order/alipay/',
        headers: {
          'X-CSRFToken': $('input[name="csrfmiddlewaretoken"]').val()
        },
        data: {'id': car_id,'flag': 'car'},
        success: function (data) {
          console.log(data.data);
          window.open(data.data)
        },
      })
  }
  deleteClick = function (id) {
    console.log(id);
    $.ajax({
      url: '/shopping_car/',
      method: "DELETE",
      headers: {'X-CSRFToken': $('input[name="csrfmiddlewaretoken"]').val()},
      data: {id: id},
      success: function (data) {
        location.reload();
      }
    });
  }
  putClick = function (id) {
    $(document).ready(function (){
      obj = '#number' + id
        number = $(obj).val()
      $.ajax({
        url: '/shopping_car/',
        method: "PUT",
        headers: {'X-CSRFToken': $('input[name="csrfmiddlewaretoken"]').val()},
        data: {id: id, number: number},
        success: function (data) {
        location.reload();
      }
      });
    })

  }

  // 支付接口
  // content = `<div class="layui-table-cell laytable-cell-1-0-1" style="height:26px; float:right;margin-top:-33px;"><span onclick="payClick()" style="background-color:#01AAED;padding: 10px;color:white; cursor: pointer;">确认支付</span></div>`
  // $(".layui-table-page").after(content);
})